import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useCertificateStore = defineStore('certificate', () => {
  // 证书列表数据
  const certificateList = ref([])
    
  // 搜索条件
  const searchParams = ref({
    institution: '',
    page: 1,
    pageSize: 10
  })
    
  // 分页信息
  const pagination = ref({
    current: 1,
    pageSize: 10,
    total: 0
  })
    
  // 加载状态
  const loading = ref(false)

  // 设置证书列表
  function setCertificateList(data) {
    certificateList.value = data
  }
    
  // 设置搜索参数
  function setSearchParams(params) {
    searchParams.value = { ...searchParams.value, ...params }
  }
    
  // 设置分页信息
  function setPagination(info) {
    pagination.value = { ...pagination.value, ...info }
  }
    
  // 设置加载状态
  function setLoading(status) {
    loading.value = status
  }

  return {
    certificateList,
    searchParams,
    pagination,
    loading,
    setCertificateList,
    setSearchParams,
    setPagination,
    setLoading
  }
})